package com.zelin.controller;

import com.zelin.pojo.Student;
import com.zelin.service.StudentService;
import com.zelin.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: Feng.Wang
 * @Company: Zelin.ShenZhen
 * @Description:
 * @Date: Create in 2019/6/25 09:46
 */
@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentService studentService;

    /**
     * 查询所有的学生
     * @return
     */
    @RequestMapping("/list")
    public List<Student> findAll(){
        return studentService.findAll();
    }

    /**
     * 条件查询带分页
     * @param page
     * @param pagesize
     * @param student
     * @return
     */
    @RequestMapping("/search")
    public PageResult<Student> search(int page, int pagesize, @RequestBody(required = false) Student student){
        PageResult<Student> pageResult = studentService.search(page,pagesize,student);
        return pageResult;
    }
}
